package com.mls.fivedistrict.server.impl;

import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.mls.fivedistrict.dao.UserRoleMapper;
import com.mls.fivedistrict.pojo.RolePermissionDict;
import com.mls.fivedistrict.pojo.UserRole;
import com.mls.fivedistrict.server.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户角色关系表 服务实现类
 * </p>
 *
 * @author Five Team
 * @since 2018-05-15
 */
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements UserRoleService {
    @Autowired
    private UserRoleMapper userRoleMapper;

    @Override
    public List<RolePermissionDict> getUserPermissionDict(Long userId) {
        List<RolePermissionDict> rolePermissionDictList = userRoleMapper.selectUserPermissionDict(userId);
        return rolePermissionDictList;
    }

    @Override
    public List<UserRole> getUserRoleByUserId(Long userId) {
        Wrapper wrapper = Condition.create().eq("user_id", userId).eq("is_delete", false);


        List<UserRole> list = userRoleMapper.selectList(wrapper);
        return list;
    }
}
